package com.lanren.common.app;

import com.lanren.common.utils.AppUtils;
import com.lanren.common.utils.md5.MD5Utils;

/**
 * @ClassName ApiUrl
 * @Description TODO  接口数据
 * @Author chongheng.wang
 * @Date 2019/10/3 20:57
 * @Version 1.0
 */
public class ApiUrl {

    /**
     * 接口地址
     */
    public static String BASE_URL = "";
    //测试
    public static final String BASE_URL_TEST = "http://192.168.0.102:8081";
//    public static final String BASE_URL_TEST = "http://47.104.200.33";
    //正式
    public static final String BASE_URL_PRODUCT = "http://47.104.200.33";

    /**
     * 区分线上和测试环境
     *
     * @param isDebug
     */
    public static void setBaseUrlDebug(boolean isDebug) {
        if (isDebug) {
            //测试环境
            BASE_URL = BASE_URL_TEST;
        } else {
            //生产环境
            BASE_URL = BASE_URL_PRODUCT;
        }
    }

    //接口
    public static class API {
        //登陆
        public static final String USER_LOGIN = "/myfamily/user/login";
        public static final String USER_TOKEN_LOGIN = "/myfamily/user/token/login";
        //注册
        public static final String USER_REGISTER = "/myfamily/user/register";
        //用户信息
        public static final String USER_INFO_UPDATE = "/myfamily/user/info/update";
        public static final String USER_INFO_GET = "/myfamily/user/info/get";
        //邮箱验证码
        public static final String USER_INFO_EMAIL_CODE = "/myfamily/user/info/email/code";
        public static final String USER_INFO_EMAIL_ADD = "/myfamily/user/info/email/add";

        //账本管理列表
        public static final String BOOK_MANAGER_LIST = "/myfamily/bookkeeping/manager/get";
        public static final String BOOK_MANAGER_ADD = "/myfamily/bookkeeping/manager/add";
        public static final String BOOK_MANAGER_DEL = "/myfamily/bookkeeping/manager/del";
        public static final String BOOK_MANAGER_UPDATE = "/myfamily/bookkeeping/manager/update";

        //CSV上传解析
        public static final String BOOK_CSV_IMPORT = "/myfamily/encrypt/upload";

        //分类
        public static final String BOOK_CLASSIFY_LIST = "/myfamily/bookkeeping/classify/get";
        public static final String BOOK_CLASSIFY_DEL = "/myfamily/bookkeeping/classify/del";
        public static final String BOOK_CLASSIFY_ADD = "/myfamily/bookkeeping/classify/add";

        //支付方式
        public static final String BOOK_PAYTYPE_ADD = "/myfamily/bookkeeping/paytype/add";
        public static final String BOOK_PAYTYPE_DEL = "/myfamily/bookkeeping/paytype/del";
        public static final String BOOK_PAYTYPE_GET = "/myfamily/bookkeeping/paytype/get";


        //账单
        public static final String BOOK_BOOKKEEPING_GET = "/myfamily/bookkeeping/get";
        public static final String BOOK_BOOKKEEPING_ADD = "/myfamily/bookkeeping/add";
        public static final String BOOK_BOOKKEEPING_DEL = "/myfamily/bookkeeping/del";
        public static final String BOOK_BOOKKEEPING_UPDATE = "/myfamily/bookkeeping/update";

        public static final String BOOK_BOOKKEEPING_GET_TOTAL = "/myfamily/bookkeeping/get/total";
        public static final String BOOK_BOOKKEEPING_GET_STATISTICS = "/myfamily/bookkeeping/get/statistics";


        //app version
        public static final String BOOK_APP_CHECK = "/myfamily/upgrade/check";

    }

    //公共header
    public static class HEADER {

        //token
        public static final String HEADER_TOKEN = "token";

        public static final String TIMESTAMP = "timestamp";

        //数字签名
        public static final String HEADER_SIGN = "sign";
        /**
         * 设备类型
         */
        public static final String HEADER_DEVICE = "device";
        public static final String VALUE_OS = "android";

        /**
         * app版本
         */
        public static final String HEADER_VERSION = "app";
        /**
         * 版本CODE
         */
        public static final String HEADER_VERSIONCODE = "versionCode";
        /**
         * 设备唯一编号
         */
        public static final String HEADER_DEVICEID = "deviceId";
        /**
         * 用户票据
         */
        public static final String HEADER_TICKET = "kylin-video-ticket";
        /**
         * Cookie
         */
        public static final String HEADER_COOKIE = "Cookie";
        /**
         * channel 渠道
         */
        public static final String HEADER_CHANNEL = "channel";

        /**
         * 官方版app传1 广告版app传2
         */
        public static final String HEADER_APP_CHANNEL = "appChannel";
        public static final String APPCHANNEL_OFFICIAL = "1";//官方版app传1
        public static final String APPCHANNEL_AD = "2";     //广告版app传2


        /**
         * 手机 IMEI
         */
        public static final String IMEI = "imei";

        /**
         * 手机 MAC
         */
        public static final String MAC = "mac";


        /**
         * 手机 AndroidID
         */
        public static final String ANDROIDID = "androidid";

        /**
         * APP简称 区分是什么应用
         */
        public static final String APPNAME = "appName";

        /**
         * 手机系统版本号
         */
        public static final String SYSTEMVERSION = "os";

        /**
         * 手机型号
         */
        public static final String MODELNO = "modelNo";

        /**
         * 手机厂商
         */
        public static final String MANUFACTURER = "manufacturer";

        /**
         * 参数类型
         */
        public static final String CONTENT_TYPE = "Content-Type";

        public static String getHeaderDeviceidValue() {
            String deviceId = AppUtils.getAndroidID()
                    + "-" + AppUtils.getPhoneProducer()
                    + "-" + AppUtils.getPhoneModel()
                    + "-" + AppUtils.getSDKVersion()
                    + "-" + AppUtils.getSystemVersion();
            return MD5Utils.MD5Encode32(deviceId);
        }

        public static String getAppSecret() {
            String deviceId = "lanren-family-app-secret";
            return MD5Utils.MD5Encode32(deviceId);
        }
    }
}
